<?php

/**
 * Description of AppRegistry
 *
 * @author gun
 */
class AppRegistry {
    
    public static function loadService($class = '') {
        
        try {
            $service = NULL;            
            $registry = new Zend_Registry();
            
            if ($registry->isRegistered($class))    
                $service = $registry->get($class);            
            else {
                if (!class_exists($class)) {
                    Zend_Loader_Autoloader::autoload($class);
                } else {
                    $newservice = new $class();
                    $registry->set($class, $newservice);
                    
                    $service = $registry->get($class);
                }
            }
            
        } catch (Exception $e) {            
            echo $e->getMessage();
        }
        
        return $service;
    }
}
